# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(arkui_c_api)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include)

aux_source_directory(src DIR_SRCS)
aux_source_directory(tlang/common DIR_COMMON_SRCS)
aux_source_directory(tlang/compiler DIR_COMPILER_SRCS)
aux_source_directory(tlang/file_reader DIR_FILE_READER_SRCS)
aux_source_directory(tlang/lexer DIR_LEXER_SRCS)
aux_source_directory(tlang/lexer/token DIR_TOKEN_SRCS)
aux_source_directory(tlang/parser DIR_PARSER_SRCS)
aux_source_directory(tlang/parser/ast DIR_AST_SRCS)
aux_source_directory(tlang/parser/ast/leaf DIR_AST_LEAF_SRCS)
aux_source_directory(tlang/parser/ast/list DIR_AST_LIST_SRCS)
aux_source_directory(tlang/parser/ast/list/expr DIR_AST_LIST_EXPR_SRCS)
aux_source_directory(tlang/parser/ast/list/function DIR_AST_LIST_FUNCTION_SRCS)
aux_source_directory(tlang/parser/ast/list/stmt DIR_AST_LIST_STMT_SRCS)
aux_source_directory(tlang/parser/ast/list/array DIR_AST_LIST_ARRAY_SRCS)
aux_source_directory(tlang/parser/ast/list/module DIR_AST_LIST_MODULE_SRCS)
aux_source_directory(tlang/parser/ast/list/clazz DIR_AST_LIST_CLASS_SRCS)
aux_source_directory(tlang/parser/ast/list/view_build DIR_AST_LIST_VIEW_BUILD_SRCS)
aux_source_directory(tlang/tvm DIR_VM_SRCS)
aux_source_directory(tlang/tvm/rt_code DIR_VM_RT_CODE_SRCS)
aux_source_directory(tlang/tvm/rt_code/constant_pool DIR_VM_RT_CODE_CONSTANT_POOL_SRCS)
aux_source_directory(tlang/tvm/rt_data DIR_VM_RT_DATA_SRCS)
aux_source_directory(tlang/tvm/instructions DIR_VM_INSTRUCTIONS_SRCS)
aux_source_directory(tlang/tvm/interpreter DIR_VM_INTERPRETER_SRCS)

add_library(entry SHARED napi_init.cpp
                                ${DIR_SRCS}
                                ${DIR_COMMON_SRCS}
                                ${DIR_COMPILER_SRCS}
                                ${DIR_FILE_READER_SRCS}
                                ${DIR_INTERPRETER_SRCS}
                                ${DIR_LEXER_SRCS}
                                ${DIR_TOKEN_SRCS}
                                ${DIR_PARSER_SRCS}
                                ${DIR_AST_SRCS}
                                ${DIR_AST_LEAF_SRCS}
                                ${DIR_AST_LIST_SRCS}
                                ${DIR_AST_LIST_EXPR_SRCS}
                                ${DIR_AST_LIST_FUNCTION_SRCS}
                                ${DIR_AST_LIST_STMT_SRCS}
                                ${DIR_AST_LIST_ARRAY_SRCS}
                                ${DIR_AST_LIST_MODULE_SRCS}
                                ${DIR_AST_LIST_CLASS_SRCS}
                                ${DIR_AST_LIST_VIEW_BUILD_SRCS}
                                ${DIR_VM_SRCS}
                                ${DIR_VM_RT_CODE_SRCS}
                                ${DIR_VM_RT_CODE_CONSTANT_POOL_SRCS}
                                ${DIR_VM_RT_DATA_SRCS}
                                ${DIR_VM_INSTRUCTIONS_SRCS}
                                ${DIR_VM_INTERPRETER_SRCS}
)

target_link_libraries(entry PUBLIC libace_napi.z.so libace_ndk.z.so)